package com.asset.dispoal.defaultRoleMenu.service.commom;

import com.asset.dispoal.defaultRoleMenu.domain.db.entity.GbDefaultRoleMenu;
import com.asset.dispoal.defaultRoleMenu.domain.db.mapper.GbDefaultRoleMenuMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import tech.mhuang.pacebox.core.ddd.BaseCommand;
import tech.mhuang.pacebox.springboot.protocol.Result;

/**
 * @author qr
 * @date 2022/3/18$
 */
@Component
public class RoleMenuModifyCommand implements BaseCommand<GbDefaultRoleMenu, Result> {

    @Autowired
    GbDefaultRoleMenuMapper gbDefaultRoleMenuMapper;

    @Override
    @Transactional
    public Result execute(GbDefaultRoleMenu gbDefaultRoleMenu) {
        if (gbDefaultRoleMenu == null) {
            return Result.faild("参数错误");
        }
        gbDefaultRoleMenuMapper.delBatch(gbDefaultRoleMenu.getRole());
        gbDefaultRoleMenuMapper.saveBatch(gbDefaultRoleMenu);
        return Result.ok();
    }
}
